var voucherList = {};
var VoucherList = function () {
    //初始化函数
    this.init = function () {
        //初始化表格
        layuiFunciton.tableInit({
            toolbar: false,
            tableId: 'voucherListTableId',
            url: layuiFunciton.URL + '/wb/voucher/findByOrderCode',
            id: 'voucherListId',
            page: false,
            searchFromId: 'formVoucher',
            totalRow: true,
            tableFilter: 'voucherListFilter',  //表格监听名称,
            cols: [[
                {type: 'numbers', title: '序号', fixed: 'left'},
                {field: 'settlementNumber', title: '结算编号', sort: true, fixed: 'left', totalRowText: '合计：'}
                , {field: 'dateReceipt', width: 120, title: '付款日期', sort: true}
                , {
                    field: 'paymentAccount', title: '收款账户', sort: true,
                    templet: function (row) {
                        return layuiFunciton.getValNameByValCode(row.paymentAccount);
                    }
                }
                , {
                    field: 'typePayer', width: 120, title: '付款方类型', sort: true,
                    templet: function (row) {
                        if (row.typePayer == 1) {
                            return "个人";
                        } else if (row.typePayer == 2) {
                            return "单位";
                        } else {
                            return "";
                        }
                    }
                }
                , {
                    field: 'drawee', width: 100, title: '付款方', sort: true,
                    templet: function (row) {
                        if (row.typePayer == 1) {
                            return row.drawee;
                        } else if (row.typePayer == 2) {
                            return layuiFunciton.getValNameByValCode(row.paymentUnit);
                        } else {
                            return "";
                        }
                    }
                }
                , {
                    field: 'paymentAmount',
                    width: 100,
                    align: "center",
                    title: '付款金额',
                    totalRowText: '<span style="color: #009feb" class="paymentAmount">0.00</span>',
                    sort: true,
                    templet: function (row) {
                        return '<span style="color: #009feb">' + Number(row.paymentAmount).toFixed(2) + '</span>';
                    }
                }
                , {
                    field: 'amountCancelVerification',
                    width: 120,
                    align: "center",
                    title: '核销金额',
                    totalRowText: '<span style="color: red" class="amountCancelVerification">0.00</span>',
                    sort: true,
                    templet: function (row) {
                        if (row.amountCancelVerification) {
                            return '<span style="color: red">' + Number(row.amountCancelVerification).toFixed(2) + '</span>';
                        } else {
                            return '<span style="color: red">0.00</span>';
                        }
                    }
                }
            ]],
            returnData: function (res) {
                var paymentAmount = 0.00, amountCancelVerification = 0.00;
                res.forEach(function (obj, index) {
                    paymentAmount = (Number(paymentAmount) + Number(obj.paymentAmount)).toFixed(2);
                    amountCancelVerification = (Number(amountCancelVerification) + Number(obj.amountCancelVerification)).toFixed(2);
                });
                $(".paymentAmount").html(paymentAmount);
                $(".amountCancelVerification").html(amountCancelVerification);
            }
        });
    };
};
function pageReady() {
    voucherList = new VoucherList();
    voucherList.init();
}
